import sys

from PyQt6.QtCore import Qt
from PyQt6.QtWidgets import QApplication, QWidget, QPushButton, QHBoxLayout


class Window(QWidget):

    def __init__(self):
        super().__init__()
        # self.setStyleSheet("background-color:green")

        # 设置窗口区域
        # 一个水平布局，区分左边菜单、右边展示
        hLay = QHBoxLayout()

        one = QWidget()
        one.setStyleSheet("background-color:blue")
        two = QWidget()
        two.setStyleSheet("background-color:red")
        # hLay.addWidget(one, 0, Qt.AlignmentFlag.AlignCenter)
        # hLay.addWidget(two, 1, Qt.AlignmentFlag.AlignCenter)
        hLay.addWidget(QPushButton("操作菜单"), 0, Qt.AlignmentFlag.AlignCenter)
        hLay.addWidget(QPushButton("显示窗口"), 0, Qt.AlignmentFlag.AlignCenter)

        self.setLayout(hLay)

    def mouseMoveEvent(self, event):
        print("鼠标移动事件 start", event.button())

        if event.button() == Qt.MouseButton.LeftButton:
            if self.isMaximized():
                self.overrideWindowState(Qt.WindowState.WindowNoState)

            else:
                self.overrideWindowState(Qt.WindowState.WindowMaximized)

    def mousePressEvent(self, event):
        print("鼠标点击事件 start", event.button())

        if event.button() == Qt.MouseButton.LeftButton:
            print("鼠标点击事件 check", event.button() == Qt.MouseButton.LeftButton)
            if self.isFullScreen():
                print("鼠标点击事件 普通化")
                self.resize(300, 300)
                self.overrideWindowState(Qt.WindowState.WindowMaximized)

            else:
                print("鼠标点击事件 最大化")
                self.resize(500, 500)
                self.overrideWindowState(Qt.WindowState.WindowFullScreen)


if __name__ == '__main__':
    app = QApplication(sys.argv)

    window = Window()
    window.resize(800, 800)

    window.setMask()
    window.show()

    sys.exit(app.exec())
